<?php
return [
    'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
    'timeZone' => 'Asia/Chongqing',
    'aliases' => [
        '@bower' => '@vendor/bower-asset',
        '@npm' => '@vendor/npm-asset',
    ],
    'bootstrap' => [
        'queue',
        'queue_sms',
        'queue_bind_phone_0',
        'queue_bind_phone_1',
        'queue_bind_phone_2',
        'queue_bind_phone_3',
        'queue_load_coupon_data',
        'queue_notice_api'
    ],
    'components' => [
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                'db' => [
                    'class' => 'yii\log\DbTarget',
                    'levels' => ['error', 'warning'],
                    'except' => ['yii\web\HttpException:*', 'yii\i18n\I18N\*'],
                    'prefix' => function () {
                        $url = !Yii::$app->request->isConsoleRequest ? Yii::$app->request->getUrl() : null;
                        return sprintf('[%s][%s]', Yii::$app->id, $url);
                    },
                    'logVars' => [],
                    'logTable' => '{{%system_log}}'
                ]
            ],
        ],
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
        ],
        'i18n' => [
            'translations' => [
                'zacksleo/yii2/backend/*' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    'basePath' => '@vendor/zacksleo/yii2-backend/src/messages',
                    'sourceLanguage' => 'en-US',
                    'fileMap' => [
                        'backend' => 'backend.php',
                    ],
                ],
                'rbac-admin' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    'sourceLanguage' => 'en',
                    'basePath' => '@mdm/admin/messages',
                ]
            ],
        ],
        'settings' => [
            'class' => 'pheme\settings\components\Settings'
        ],
        'redis' => [
            'class' => 'yii\redis\Connection',
            'hostname' => 'redis',
            'port' => '6379',
            'database' => 0,
        ],
        'redis_sms' => [
            'class' => 'yii\redis\Connection',
            'hostname' => 'redis',
            'port' => '6379',
            'database' => 1,
        ],
        'redis_bind_phone_0' => [
            'class' => 'yii\redis\Connection',
            'hostname' => 'redis',
            'port' => '6379',
            'database' => 2,
        ],
        'redis_bind_phone_1' => [
            'class' => 'yii\redis\Connection',
            'hostname' => 'redis',
            'port' => '6379',
            'database' => 3,
        ],
        'redis_bind_phone_2' => [
            'class' => 'yii\redis\Connection',
            'hostname' => 'redis',
            'port' => '6379',
            'database' => 4,
        ],
        'redis_bind_phone_3' => [
            'class' => 'yii\redis\Connection',
            'hostname' => 'redis',
            'port' => '6379',
            'database' => 5,
        ],
        'redis_load_coupon_data' => [
            'class' => 'yii\redis\Connection',
            'hostname' => 'redis',
            'port' => '6379',
            'database' => 6,
        ],
        'redis_notice_api' => [
            'class' => 'yii\redis\Connection',
            'hostname' => 'redis',
            'port' => '6379',
            'database' => 7,
        ],
        'cache' => [
            'class' => 'yii\redis\Cache'
        ],
        /**
         * @ \yii\mongodb\Connection Component
         */
        'mongo' => [
            'class' => 'yii\mongodb\Connection',
            'dsn' => getenv("MONGO_DNS"),

        ],
        'queue' => [
            'class' => \yii\queue\redis\Queue::class,
            'redis' => 'redis',
            'channel' => 'queue',
            'as log' => \yii\queue\LogBehavior::class
        ],
        'queue_sms' => [
            'class' => \yii\queue\redis\Queue::class,
            'redis' => 'redis_sms',
            'channel' => 'queue_sms',
            'as log' => \yii\queue\LogBehavior::class
        ],
        'queue_bind_phone_0' => [
            'class' => \yii\queue\redis\Queue::class,
            'redis' => 'redis_bind_phone_0',
            'channel' => 'queue_bind_phone_0',
            'as log' => \yii\queue\LogBehavior::class
        ],
        'queue_bind_phone_1' => [
            'class' => \yii\queue\redis\Queue::class,
            'redis' => 'redis_bind_phone_1',
            'channel' => 'queue_bind_phone_1',
            'as log' => \yii\queue\LogBehavior::class
        ],
        'queue_bind_phone_2' => [
            'class' => \yii\queue\redis\Queue::class,
            'redis' => 'redis_bind_phone_2',
            'channel' => 'queue_bind_phone_2',
            'as log' => \yii\queue\LogBehavior::class
        ],
        'queue_bind_phone_3' => [
            'class' => \yii\queue\redis\Queue::class,
            'redis' => 'redis_bind_phone_3',
            'channel' => 'queue_bind_phone_3',
            'as log' => \yii\queue\LogBehavior::class
        ],
        'queue_load_coupon_data' => [
            'class' => \yii\queue\redis\Queue::class,
            'redis' => 'redis_load_coupon_data',
            'channel' => 'queue_load_coupon_data',
            'as log' => \yii\queue\LogBehavior::class
        ],
        'queue_notice_api' => [
            'class' => \yii\queue\redis\Queue::class,
            'redis' => 'redis_notice_api',
            'channel' => 'queue_notice_api',
            'as log' => \yii\queue\LogBehavior::class
        ],
        'awss3Fs' => [
            'class' => 'common\helpers\files\AwsS3Filesystem',
            'key' => getenv('OSS_KEY'),
            'secret' => getenv('OSS_SECRET'),
            'bucket' => getenv('OSS_BUCKET'),
            'region' => getenv('OSS_REGION'),
            // 'version' => 'latest',
            'baseUrl' => getenv('OSS_BASE_URL'),
            // 'prefix' => 'your-prefix',
            // 'options' => [],
            'use_path_style_endpoint' => true,
            'endpoint' => getenv('OSS_ENDPOINT'),
        ],
    ],
];
